/**
 * @Company 
 * @Title: LoginController.java 
 * @Package com.jbinfo.qingcaowan.app.controller 
 * @author lizhenwei
 * @date 2016-07-11 下午1:06:21 
 * @version V1.0   
 */
package com.jbinfo.qingcaowan.app.controller;

import java.util.Date;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jbinfo.qingcaowan.common.ClonePojoUtil;
import com.jbinfo.qingcaowan.studyManager.dto.RemarkDTO;
import com.jbinfo.qingcaowan.studyManager.entity.Remark;
import com.jbinfo.qingcaowan.studyManager.service.RemarkService;
import com.jbinfo.qingcaowan.user.dto.UserDTO;

/**
 * @ClassName: LoginController
 * @Description: 评论controller
 * @author lizhenwei
 */
/**
 * @author Administrator
 *
 */
@Controller
public class RemarkController {

	private static final Logger LOG = LoggerFactory.getLogger(RemarkController.class);

	@Resource
	private RemarkService remarkService;
	
	@RequestMapping(value = "/{client}/saveRemark")
	public @ResponseBody
	Object saveRemark(@PathVariable("client") String client, UserDTO userDTO, RemarkDTO remarkDTO) {
		LOG.info("客户端为 " + client + " remarkDTO：" + remarkDTO.toString());
		
//		LoginContext loginContext = LoginContextUtil.getLoginContext(session);
//		
//		UserDTO userDTO = loginContext.getLoginUser();
		String userId = userDTO.getUserId();
		
		remarkDTO.setUserid(userId);
		remarkDTO.setRemarkTime(new Date());
		remarkDTO.setIsshow("0");
		
		Remark remark = ClonePojoUtil.copyClassFromTo(remarkDTO, Remark.class);
		
		return remarkService.saveRemarkInfo(remark);
	}

}
